package it.polimi.TravelDream;

import java.io.Serializable;

import javax.persistence.*;

import java.util.Date;
import java.util.List;


/**
 * The persistent class for the excursion database table.
 * 
 */
@Entity
@NamedQueries({
@NamedQuery(name="Excursion.findAll", query="SELECT e FROM Excursion e"),
@NamedQuery(name="Excursion.searchQuery", query="SELECT e FROM Excursion e WHERE e.date >= :param1 and e.city LIKE :param2")
})
public class Excursion implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

	@Temporal(TemporalType.DATE)
	private Date addDate;

	private int capacity;

	private String city;

	@Temporal(TemporalType.DATE)
	private Date date;

	private String description;

	private String name;

	private int price;

	private String type;

	private String website;

	//bi-directional many-to-one association to Packexlinker
	@OneToMany(mappedBy="excursion")
	private List<Packexlinker> packexlinkers;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="AddedBy")
	private User user;

	public Excursion() {
		super();
	}

	
	
	public Excursion(ExcursionDTO excursion) {
		this.id = excursion.getId();
		this.addDate = new Date();
		this.capacity = excursion.getCapacity();
		this.city = excursion.getCity();
		this.date = excursion.getDate();
		this.description = excursion.getDescription();
		this.name = excursion.getName();
		this.price = excursion.getPrice();
		this.type = excursion.getType();
		this.website = excursion.getWebsite();
//		this.user = user;
	}



	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getAddDate() {
		return this.addDate;
	}

	public void setAddDate(Date addDate) {
		this.addDate = addDate;
	}

	public int getCapacity() {
		return this.capacity;
	}

	public void setCapacity(int capacity) {
		this.capacity = capacity;
	}

	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public Date getDate() {
		return this.date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPrice() {
		return this.price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getWebsite() {
		return this.website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public List<Packexlinker> getPackexlinkers() {
		return this.packexlinkers;
	}

	public void setPackexlinkers(List<Packexlinker> packexlinkers) {
		this.packexlinkers = packexlinkers;
	}

	public Packexlinker addPackexlinker(Packexlinker packexlinker) {
		getPackexlinkers().add(packexlinker);
		packexlinker.setExcursion(this);

		return packexlinker;
	}

	public Packexlinker removePackexlinker(Packexlinker packexlinker) {
		getPackexlinkers().remove(packexlinker);
		packexlinker.setExcursion(null);

		return packexlinker;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}